<?php defined('SYSPATH') or die('No direct script access.');

class Controller_Wechat extends Stourweb_Controller
{
    /*
     * 微信公众号云平台
     * */
    public function before()
    {
        parent::before();

        $this->assign('parentkey', $this->params['parentkey']);
        $this->assign('itemid', $this->params['itemid']);
    }

    //公众平台首页
    public function action_index2()
    {
        $this->display('stourtravel/config/app_id_setting2');
    }

    //公众平台首页
    public function action_index()
    {
        include(Kohana::find_file('data', 'license'));
        $authorize_code = $SerialNumber;
        $this->write_authorize_code_to_front($authorize_code);
        $domain = $GLOBALS['cfg_basehost'];
        $wechat_cloud_url = 'http://wechat.stourweb.com/front/login/?authorize_code='.$authorize_code.'&domain='.$domain;
        $this->request->redirect($wechat_cloud_url);

    }

    //写序列号到前台便于调用.
    private  function write_authorize_code_to_front($code)
    {
        $params = array(
            'cfg_authorize_code' => $code,
            'webid' =>0
        );
        $model = new Model_Sysconfig();
        $model->saveConfig($params);

        return true;
    }




}